package com.qiangesoft.blog.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qiangesoft.blog.common.result.ResponseResult;
import com.qiangesoft.blog.system.entity.SysWebConfig;
import com.qiangesoft.blog.system.mapper.SysWebConfigMapper;
import com.qiangesoft.blog.system.service.ISysWebConfigService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import static com.qiangesoft.blog.common.constants.FieldConstants.LIMIT_ONE;

/**
 * <p>
 * 网站配置 服务实现类
 * </p>
 *
 * @author qiange
 * @since 2023-06-01
 */
@Service
@RequiredArgsConstructor
public class SysWebConfigServiceImpl extends ServiceImpl<SysWebConfigMapper, SysWebConfig> implements ISysWebConfigService {

    @Override
    public ResponseResult listWebConfig() {
        SysWebConfig webConfig = baseMapper.selectOne(new QueryWrapper<SysWebConfig>()
                .last(LIMIT_ONE));
        return ResponseResult.success(webConfig);
    }

    @Override
    public void updateWebConfig(SysWebConfig webConfig) {
        baseMapper.updateById(webConfig);
    }
}
